package com.cxy.dao;

import java.util.List;

import org.hibernate.Query;
import org.springframework.stereotype.Repository;

import com.cxy.pojo.User;
@Repository
public class UserDao  extends BaseDao<User, Integer> {
	public User login(User user){
		String hql = "from User where userName=? and password = ?";
		Query query = getSession().createQuery(hql);
		query.setParameter(0, user.getUserName());
		query.setParameter(1, user.getPassword());
		return (User) query.uniqueResult();
	}
	@SuppressWarnings("unchecked")
	public List<User> findByNotPid(int pid){
		String sql = "SELECT id,username,PASSWORD,isenable,createtime FROM t_user WHERE id NOT IN(SELECT uid FROM t_project_user WHERE pid =" + pid + " )";
		Query query = getSession().createSQLQuery(sql).addEntity(User.class);
		return query.list();
	}
}
